<?php
class Admin_Forms_LoginForm extends Zend_Form {
	function init() {
		$this->setAction('')
				->setMethod('POST')
				->setAttrib('class','form-horizontal');
		$user_name = $this->createElement('text', 'username');
		$user_name->addValidator ( 'regex', false, array ('/^[a-z]+/' ) )
		            ->addValidator ( 'stringLength', false, array (3, 20 ) )
		            ->setRequired ( true )
		            ->addFilter ( 'StringToLower' )
		            ->addFilter('StringTrim')
		            ->setAttrib('class','form-control')
		            ->setLabel('Tài khoản');
		$password = $this->createElement ( 'password', 'password' );
		$password->addValidator ( 'StringLength', false, array (6 ) )
					->setRequired ( true )
					->setAttrib('class','form-control')
					->setLabel('Mật khẩu');
		
        	     
		$submit = $this->createElement('submit','login',array ('label' => 'Đăng nhập' ,'class'	=>'btn btn-default'));
		$remember = $this->createElement('checkbox','remember',array ('label'	=> 'Ghi nhớ đăng nhập'));
		$this->addElement($user_name)
				->addElement($password)
				->addElement($remember)
				->addElement($submit);
		$this->setDecorators(array('FormElements',array('HtmlTag',array('tag'	=> 'div','width'=>'100%')),'form'));
		$this->setElementDecorators(array(
										'ViewHelper',
										'Errors',
										'Description',
										array(	
											array('data'	=> 'HtmlTag'),
											array('tag'		=> 'div','class'	=> 'col-md-6')),
										array('label',
											array('class'	=> 'col-md-3 control-label')),
										array(
											array('row'	=> 'HtmlTag',),
											array('class'=>'form-group')
		        						)
									)
								);
		$submit->setDecorators(array(
								'ViewHelper',
								array(
									array('data'	=> 'HtmlTag'),
									array('tag'		=>	'div','class'	=> 'col-md-9 col-md-offset-3')
								),
								array(
									array('row'	=> 'HtmlTag'),
									array('tag'	=> 'div',"class"	=> "form-group"))
									));
		$remember->setDecorators(array(
								'ViewHelper',
								array(
									array('data'	=> 'HtmlTag'),
									array('tag'		=>	'span','for'=>'remember',"openOnly"	=> true,'class'	=> "col-md-9 col-md-offset-3")
								),
								array('label',
											array("placement"	=> Zend_Form_Decorator_PrepareElements::APPEND),"closeOnly"	=> true,'escape' => false),
								array(
									array('row'	=> 'HtmlTag'),
									array('tag'	=> 'div','class'	=> "form-group"))
									));
	}
}